package com.vincent.utils;

/**
 * Created by wensen on 2016/12/8.
 * 选票信息
 * round: 轮次
 * leader_id: leader id
 */
public class BallotNumber implements Comparable<BallotNumber>{

    private final long round;
    private final int leader_id;

    public BallotNumber(long rd, int leader) {
        this.round = rd;
        this.leader_id = leader;
    }

    public long round() {
        return this.round;
    }

    public int leader_id() {
        return this.leader_id;
    }

    public String toString() {
        return "{BallotNumber [round: " + this.round
                + " leader: " + leader_id + "]}";
    }

    public int compareTo(BallotNumber o) {
        if (this.round > o.round) return 1;
        else if (this.round < o.round) return -1;
        else {
            return this.leader_id - o.leader_id;
        }
    }
}
